home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / inet / internet-drafts / draft-ietf-822ext-enriched-01.txt < prev    next >
Text File  |  1993-04-14  |  43KB  |  1,027 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.             Network Working Group               N. Borenstein, Bellcore
  7.             INTERNET DRAFTS                                  April 1993
  8.  
  9.  
  10.  
  11.                         The text/enriched MIME Content-type
  12.  
  13.  
  14.             Status of this Memo
  15.  
  16.  
  17.             This document is an Internet  Draft.   Internet  Drafts  are
  18.             working  documents  of  the  Internet Engineering Task Force
  19.             (IETF), its Areas, and its Working Groups. Note  that  other
  20.             groups  may  also  distribute  working documents as Internet
  21.             Drafts.
  22.  
  23.             Internet Drafts are draft documents valid for a  maximum  of
  24.             six  months.   Internet  Drafts may be updated, replaced, or
  25.             obsoleted by  other  documents  at  any  time.   It  is  not
  26.             appropriate  to use Internet Drafts as reference material or
  27.             to cite them other than as a "working  draft"  or  "work  in
  28.             progress."
  29.  
  30.             Please check the I-D  abstract  listing  contained  in  each
  31.             Internet Draft directory to learn the current status of this
  32.             or any  other Internet Draft.
  33.  
  34.             Abstract
  35.  
  36.  
  37.             MIME [RFC-1341,  RFC-MIME]  defines  a  format  and  general
  38.             framework  for  the representation of a wide variety of data
  39.             types  in  Internet  mail.   This   document   defines   one
  40.             particular  type  of  MIME  data,  the text/enriched type, a
  41.             refinement of the "text/richtext" type defined in RFC  1341.
  42.             The  text/enriched  MIME  type is intended to facilitate the
  43.             wider interoperation of simple enriched text across  a  wide
  44.             variety of hardware and software platforms.
  45.  
  46.             The Text/enriched MIME type
  47.  
  48.  
  49.             In order to promote the  wider  interoperability  of  simple
  50.             formatted  text,  this  document defines an extremely simple
  51.             subtype of the MIME content-type "text", the "text/enriched"
  52.  
  53.  
  54.  
  55.             Borenstein - text/eExpires September 1, 1993          Page 1
  56.  
  57.  
  58.  
  59.  
  60.             Borenstein     A text/enriched type for MIME  April 1993 [2]
  61.  
  62.  
  63.             subtype.   This  subtype  was designed to meet the following
  64.             criteria:
  65.  
  66.                  1.  The syntax must be extremely simple to  parse,
  67.                  so  that  even  teletype-oriented mail systems can
  68.                  easily strip away the formatting  information  and
  69.                  leave only the readable text.
  70.  
  71.                  2.  The syntax must be extensible to allow for new
  72.                  formatting  commands that are deemed essential for
  73.                  some application.
  74.  
  75.                  3.  If the character set in use is ASCII or an  8-
  76.                  bit  ASCII superset, then the raw form of the data
  77.                  must   be   readable   enough   to   be    largely
  78.                  unobjectionable  in the event that it is displayed
  79.                  on the screen of the user of a non-MIME-conformant
  80.                  mail reader.
  81.  
  82.                  4.  The capabilities must be extremely limited, to
  83.                  ensure  that  it  can  represent  no  more than is
  84.                  likely to be representable by the  user's  primary
  85.                  word  processor.   While  this  limits what can be
  86.                  sent, it increases the  likelihood  that  what  is
  87.                  sent can be properly displayed.
  88.  
  89.             This   document   defines   a   new    MIME    content-type,
  90.             "text/enriched".   The  content-type  line for this type may
  91.             have two optional parameters, "opentoken" and  "closetoken",
  92.             which   define   the   special  characters  that  delimit  a
  93.             formatting token.  By default, these tokens are "<" and ">".
  94.             Thus the following two content-type lines are equivalent:
  95.  
  96.                  Content-type: text/enriched
  97.                  Content-type: text/enriched; opentoken="<";
  98.                  closetoken=">"
  99.  
  100.             Most of this document is written under the  assumption  that
  101.             the default opentoken and closetoken values are used.  It is
  102.             STRONGLY RECOMMENDED that no other opentoken  or  closetoken
  103.             values  be  used without a very good reason.  The only known
  104.             good reason  is  discussed  in  the  section  on  "Non-ASCII
  105.             Character Sets".
  106.  
  107.             The syntax of "text/enriched" is very simple.  It represents
  108.             text  in  a  single  character  set  -- US-ASCII by default,
  109.  
  110.  
  111.  
  112.             Borenstein - text/eExpires September 1, 1993          Page 2
  113.  
  114.  
  115.  
  116.  
  117.             Borenstein     A text/enriched type for MIME  April 1993 [3]
  118.  
  119.  
  120.             although a different character set can be specified  by  the
  121.             use of a "charset" parameter, as with the "text/plain" type.
  122.             (The semantics of text/enriched in non-ASCII character  sets
  123.             are  discussed  later  in  this  document.)   All characters
  124.             represent  themselves,  with  the  exception  of   the   "<"
  125.             character (ASCII 60), which is used to mark the beginning of
  126.             a formatting command.  Formatting  instructions  consist  of
  127.             formatting  commands   surrounded  by  angle brackets ("<>",
  128.             ASCII 60 and 62).  Each formatting command may  be  no  more
  129.             than 60 characters in length, all in US-ASCII, restricted to
  130.             the alphanumeric and  hyphen  ("-")  characters.  Formatting
  131.             commands  may  be  preceded  by  a  solidus ("/", ASCII 47),
  132.             making them negations, and such negations must always  exist
  133.             to  balance  the  initial  opening  commands.   Thus, if the
  134.             formatting command "<bold>" appears  at  some  point,  there
  135.             must  later  be  a  "</bold>" to balance it.  (NOTE:  The 60
  136.             character limit on formatting commands does NOT include  the
  137.             "<",  ">",  or "/" characters that might be attached to such
  138.             commands.)
  139.  
  140.             Beyond tokens delimited by "<" and ">", there are two  other
  141.             special  processing  rules.  First, a literal less-than sign
  142.             ("<")  can  be  represented  by  a  sequence  of  two   such
  143.             characters,  "<<".    Second,  line  breaks  (CRLF  pairs in
  144.             standard network representation) are handled specially.   In
  145.             particular, isolated CRLF pairs are translated into a single
  146.             SPACE character.  Sequences of  N  consecutive  CRLF  pairs,
  147.             however,  are  translated into N-1 actual line breaks.  This
  148.             permits long lines of data to be represented in  a  natural-
  149.             looking  manner  despite  the  frequency of line-wrapping in
  150.             Internet  mailers.   When  preparing  the  data   for   mail
  151.             transport,  isolated line breaks should be inserted wherever
  152.             necessary to keep each  line  shorter  than  80  characters.
  153.             When  preparing  such  data  for  presentation  to the user,
  154.             isolated line breaks should be replaced by  a  single  SPACE
  155.             character,  and N consecutive CRLF pairs should be presented
  156.             to the user as N-1 line breaks.
  157.  
  158.             Thus text/enriched data that looks like this:
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.             Borenstein - text/eExpires September 1, 1993          Page 3
  170.  
  171.  
  172.  
  173.  
  174.             Borenstein     A text/enriched type for MIME  April 1993 [4]
  175.  
  176.  
  177.                  This is
  178.                  a single
  179.                  line
  180.  
  181.                  This is the
  182.                  next line.
  183.  
  184.  
  185.                  This is the
  186.                  next paragraph.
  187.  
  188.             should  be  displayed  by  a  text/enriched  interpreter  as
  189.             follows:
  190.  
  191.                  This is a single line
  192.                  This is the next line.
  193.  
  194.                  This is the next paragraph.
  195.  
  196.             The  formatting  commands,  not  all  of   which   will   be
  197.             implemented  by  all  implementations,  are described in the
  198.             following sections.
  199.  
  200.             Formatting Commands
  201.  
  202.  
  203.             The  text/enriched  formatting  commands  all   begin   with
  204.             <commandname>  and  end  with  </commandname>, affecting the
  205.             formatting of  the  text  between  those  two  tokens.   The
  206.             commands are described here, grouped according to type.
  207.  
  208.             Font-Alteration Commands
  209.  
  210.             The following formatting commands are intended to alter  the
  211.             font  in  which  text  is  displayed,  but  not to alter the
  212.             indentation or justification state of the text:
  213.  
  214.                  Bold -- causes the affected text to be in a bold  font.
  215.                       Nested  bold  commands  have  the same effect as a
  216.                       single bold command.
  217.                  Italic -- causes the affected text to be in  an  italic
  218.                       font.  Nested italic commands have the same effect
  219.                       as a single italic command.
  220.                  Fixed -- causes the affected text  to  be  in  a  fixed
  221.                       width  font.   Nested fixed commands have the same
  222.                       effect as a single fixed command.
  223.  
  224.  
  225.  
  226.             Borenstein - text/eExpires September 1, 1993          Page 4
  227.  
  228.  
  229.  
  230.  
  231.             Borenstein     A text/enriched type for MIME  April 1993 [5]
  232.  
  233.  
  234.                  Smaller -- causes the affected text to be in a  smaller
  235.                       font.   It  is  recommended  that the font size be
  236.                       changed by two points, but other  amounts  may  be
  237.                       more  appropriate  in  some  environments.  Nested
  238.                       smaller commands produce  ever-smaller  fonts,  to
  239.                       the  limits  of  the  implementation's capacity to
  240.                       reasonably  display  them,  after  which   further
  241.                       smaller commands have no incremental effect.
  242.                  Bigger -- causes the affected text to be  in  a  bigger
  243.                       font.   It  is  recommended  that the font size be
  244.                       changed by two points, but other  amounts  may  be
  245.                       more  appropriate  in  some  environments.  Nested
  246.                       bigger commands produce ever-bigger fonts, to  the
  247.                       limits   of   the   implementation's  capacity  to
  248.                       reasonably  display  them,  after  which   further
  249.                       bigger commands have no incremental effect.
  250.                  Underline -- causes the affected text to be underlined.
  251.                       Nested  underline commands have the same effect as
  252.                       a single underline command.
  253.  
  254.             While the "bigger" and "smaller" operators  are  effectively
  255.             inverses,   it   is   not   recommened,  for  example,  that
  256.             "<smaller>" be used  to end the effect of "<bigger>".   This
  257.             is properly done with "</bigger>".
  258.  
  259.             Justification Commands
  260.  
  261.             Initially, text/enriched text is intended  to  be  displayed
  262.             fully-justified  with appropriate fill, kerning, and letter-
  263.             tracking as suits the capabilities  of  the  receiving  user
  264.             agent software.  Actual line width is left to the discretion
  265.             of  the  receiver,  which  is   expected   to   fold   lines
  266.             intelligently  (prefering  soft  line breaks) to the best of
  267.             its ability.
  268.  
  269.             The following commands alter  that  state.   Each  of  these
  270.             commands  force a line break before and after the formatting
  271.             command if  there  is  not  otherwise  a  line  break.   For
  272.             example, if one of these commands occurs anywhere other than
  273.             the beginning of a line of text as presented, a new line  is
  274.             begun.
  275.  
  276.                  Center -- causes the affected text to be centered.
  277.                  FlushLeft -- causes  the  affected  text  to  be  left-
  278.                       justified with a ragged right margin.
  279.  
  280.  
  281.  
  282.  
  283.             Borenstein - text/eExpires September 1, 1993          Page 5
  284.  
  285.  
  286.  
  287.  
  288.             Borenstein     A text/enriched type for MIME  April 1993 [6]
  289.  
  290.  
  291.                  FlushRight -- causes the affected  text  to  be  right-
  292.                       justified with a ragged left margin.
  293.  
  294.             The center, flushleft, and flushright commands are  mutually
  295.             exclusive,   and,  when  nested,  the  inner  command  takes
  296.             precedence.
  297.  
  298.             Note  that  for  some   non-ASCII   character   sets,   full
  299.             justification  may  be inappropriate. In these cases, a user
  300.             agent may choose not to justify such data.
  301.  
  302.             Indentation Commands
  303.  
  304.             Initially, text/enriched text is displayed using the maximum
  305.             available  margins.   Two formatting commands may be used to
  306.             affect the margins.
  307.  
  308.                  Indent -- causes the running left margin to be moved to
  309.                       the  right.  The recommended indentation change is
  310.                       the width of four characters, but this may  differ
  311.                       among implementations.
  312.                  IndentRight -- causes the running right  margin  to  be
  313.                       moved  to  the  left.  The recommended indentation
  314.                       change is the width of four characters,  but  this
  315.                       may differ among implementations.
  316.  
  317.             A line break is NOT forced by a change  of  the  margin,  to
  318.             permit  the description of "hanging" text.  Thus for example
  319.             the following text:
  320.  
  321.             Now <indent> is the time for all good horses to come to  the
  322.             aid  of  their stable, assuming that </indent> any stable is
  323.             really stable.
  324.  
  325.             would be displayed in a 40-character-wide window as follows:
  326.  
  327.             Now is the time for all good horses to
  328.                 come to the aid of their stable,
  329.                 assuming that any stable is
  330.             really stable.
  331.  
  332.             Miscellaneous Commands
  333.  
  334.                  Excerpt -- causes the affected text to  be  interpreted
  335.                       as a textual excerpt from another source, probably
  336.                       a message being responded to.  Typically this will
  337.  
  338.  
  339.  
  340.             Borenstein - text/eExpires September 1, 1993          Page 6
  341.  
  342.  
  343.  
  344.  
  345.             Borenstein     A text/enriched type for MIME  April 1993 [7]
  346.  
  347.  
  348.                       be  displayed  using  indentation and an alternate
  349.                       font, or by indenting  lines  and  preceding  them
  350.                       with  ">  ",  but  such  decisions  are  up to the
  351.                       implementation.  (Note that this is the only truly
  352.                       declarative markup construct in text/enriched, and
  353.                       as such doesn't  fit  very  well  with  the  other
  354.                       facilities, but it describes a type of markup that
  355.                       is  very  commonly  used  in  email  and  has   no
  356.                       procedural  analogue.)    Note  that  as  with the
  357.                       justification  commands,   the   excerpt   command
  358.                       implicitly  begins  and  ends with a line break if
  359.                       one is not already there.
  360.                  Verbatim -- causes the affected text  to  be  displayed
  361.                       without filling, justification, any interpretation
  362.                       of embedded  formatting  commands,  or  the  usual
  363.                       special  rules  for CRLF handling.  Note, however,
  364.                       that the  end  token  </verbatim>  must  still  be
  365.                       recognized.
  366.                  Comment -- causes the affected text to  be  interpreted
  367.                       as a comment, and hence not shown to the reader.
  368.                  Extension  --  marks  the  affected  text  as  extended
  369.                       commands.  If the extension set in use (as defined
  370.                       below, under  "Extensions  to  richtext")  is  not
  371.                       recognized   by   the   local   interpreter,  then
  372.                       "<extension>"   and   "</extension>"   should   be
  373.                       interpreted   as   synonyms  for  "<comment>"  and
  374.                       "</comment>".
  375.  
  376.             Note that while the absence of a quoting mechanism makes  it
  377.             slightly   challenging   to   include   the  literal  string
  378.             "</verbatim>" inside of a verbatim environment,  it  can  be
  379.             done  by  breaking up the verbatim segment into two verbatim
  380.             segments as follows:
  381.  
  382.                  <verbatim>
  383.                  ...slightly challenging to include the literal string
  384.                  "</</verbatim><verbatim>verbatim>" inside of a verbatim
  385.                  environment...
  386.                  </verbatim>
  387.  
  388.             Balancing and Nesting of Formatting Commands
  389.  
  390.             Pairs of formatting commands must be properly  balanced  and
  391.             nested.  Thus, a proper way to describe text in bold italics
  392.             is:
  393.  
  394.  
  395.  
  396.  
  397.             Borenstein - text/eExpires September 1, 1993          Page 7
  398.  
  399.  
  400.  
  401.  
  402.             Borenstein     A text/enriched type for MIME  April 1993 [8]
  403.  
  404.  
  405.                       <bold><italic>the-text</italic></bold>
  406.  
  407.                  or, alternately,
  408.  
  409.                       <italic><bold>the-text</bold></italic>
  410.  
  411.                  but,  in  particular,  the  following  is  illegal
  412.                  text/enriched:
  413.  
  414.                       <bold><italic>the-text</bold></italic>
  415.  
  416.             The nesting requirement for formatting  commands  imposes  a
  417.             slightly  higher  burden upon the composers of text/enriched
  418.             bodies, but potentially simplifies text/enriched  displayers
  419.             by  allowing  them  to  be  stack-based.   The  main goal of
  420.             text/enriched is to be  simple  enough  to  make  multifont,
  421.             formatted  email  widely  readable,  so  that those with the
  422.             capability of  sending  it  will  be  able  to  do  so  with
  423.             confidence.   Thus  slightly  increased  complexity  in  the
  424.             composing software was  deemed  a  reasonable  tradeoff  for
  425.             simplified  reading  software.  Nonetheless, implementors of
  426.             text/enriched readers are encouraged to follow  the  general
  427.             Internet  guidelines  of being conservative in what you send
  428.             and liberal in what you accept.  Those implementations  that
  429.             can  do so are encouraged to deal reasonably with improperly
  430.             nested text/enriched data.
  431.  
  432.             Unrecognized formatting commands
  433.  
  434.             Implementations  must  regard  any  unrecognized  formatting
  435.             command  as "no-op" commands, that is, as commands having no
  436.             effect,   thus    facilitating    future    extensions    to
  437.             "text/enriched".  Private  extensions  may  be defined using
  438.             formatting commands that begin  with  "X-",  by  analogy  to
  439.             Internet mail header field names.
  440.  
  441.             A mechanism for formally defining sets of extension commands
  442.             is given later in this document.
  443.  
  444.             "White Space" in Text/enriched Data
  445.  
  446.  
  447.             No special behavior is required for the SPACE  or  TAB  (HT)
  448.             character.   It is recommended, however, that, at least when
  449.             fixed-width fonts are in use, the common  semantics  of  the
  450.             TAB  (HT) character should be observed, namely that it moves
  451.  
  452.  
  453.  
  454.             Borenstein - text/eExpires September 1, 1993          Page 8
  455.  
  456.  
  457.  
  458.  
  459.             Borenstein     A text/enriched type for MIME  April 1993 [9]
  460.  
  461.  
  462.             to the next column position that is a multiple  of  8.   (In
  463.             other  words,  if  a  TAB (HT) occurs in column n, where the
  464.             leftmost column is column 0, then that TAB  (HT)  should  be
  465.             replaced  by  8-(n mod 8) SPACE characters.)  It should also
  466.             be noted that some mail gateways are  notorious  for  losing
  467.             (or, less commonly, adding) white space at the end of lines,
  468.             so reliance on SPACE or TAB characters at the end of a  line
  469.             is not recommended.
  470.  
  471.             Initial State of a text/enriched interpreter
  472.  
  473.  
  474.             Text/enriched  is  assumed  to  begin  with  filled,   fully
  475.             justified text in a variable-width font in a normal typeface
  476.             and a size that is average for the current display and user.
  477.             The  left  and right margins are assumed to be maximal, that
  478.             is, at the leftmost and rightmost acceptable positions.
  479.  
  480.             Non-ASCII character sets
  481.  
  482.  
  483.             If the character set specified by the charset  parameter  on
  484.             the  Content-type  line  is  anything other than "US-ASCII",
  485.             this means that the text being  described  by  text/enriched
  486.             formatting   commands   is  in  a  non-ASCII  characer  set.
  487.             However, the commands themselves are still  the  same  ASCII
  488.             commands that are defined in this document.  This creates an
  489.             ambiguity only with reference  to  the  "<"  character,  the
  490.             octet with numeric value 60.  In single byte character sets,
  491.             such as the ISO-8859 family, this  is  not  a  problem;  the
  492.             octet  60  can  be quoted by including it twice, just as for
  493.             ASCII.  The problem is more  complicated,  however,  in  the
  494.             case  of multi-byte character sets, where the octet 60 might
  495.             appear at any point in the byte sequence for any of  several
  496.             characters.   It  is  precisely  for  such  cases  that  the
  497.             "opentoken" and "closetoken"  content-type  parameters  were
  498.             defined.
  499.  
  500.             When a multibyte character set  is  used  for  text/enriched
  501.             data,   it   may   make   sense   to   choose  an  alternate
  502.             representation  for  delimiting   formatting   tokens.    In
  503.             particular,  it  may  be  most natural to choose a multibyte
  504.             string.   If  such  a  string  is   chosen,   it   MUST   be
  505.             representable as US-ASCII.  That is, each of the octets must
  506.             correspond to a normal ASCII octet that can  legally  appear
  507.             in  a Content-type parameter.  (It is conjectured that there
  508.  
  509.  
  510.  
  511.             Borenstein - text/eExpires September 1, 1993          Page 9
  512.  
  513.  
  514.  
  515.  
  516.             Borenstein     A text/enriched type for MIME April 1993 [10]
  517.  
  518.  
  519.             will never be a character set in which it is  impossible  to
  520.             choose a multibyte delimiter string that cannot be viewed as
  521.             ASCII.  If this conjecture is incorrect, a  new  version  of
  522.             text/enriched  will  have  to  be defined for that character
  523.             set.)
  524.  
  525.             Thus, for example, in a  16-bit  character  set,  one  might
  526.             choose
  527.  
  528.             Content-type: text/enriched; opentoken="<<"; closetoken=">>"
  529.  
  530.             and one could represent the literal 2-octet sequence "<<" as
  531.             "<<<<".
  532.  
  533.             Minimal text/enriched conformance
  534.  
  535.  
  536.             A minimal text/enriched implementation is  one  that  simply
  537.             recognizes   the   beginning   and   ending   of  "verbatim"
  538.             environments and, outside of them,  converts  "<<"  to  "<",
  539.             removes  everything between a <comment> command and the next
  540.             balancing </comment> command, removes all  other  formatting
  541.             commands (all text enclosed in angle brackets), converts any
  542.             series of n CRLFs to n-1 CRLFs, and converts any  lone  CRLF
  543.             pairs to SPACE.
  544.  
  545.             Notes for Implementors
  546.  
  547.  
  548.             It is recognized that implementors of  future  mail  systems
  549.             will  want rich text functionality far beyond that currently
  550.             defined for text/enriched.  The intent of  text/enriched  is
  551.             to provide a common format for expressing that functionality
  552.             in a form in which much of it, at least, will be  understood
  553.             by  interoperating  software.  Thus, in particular, software
  554.             with a richer notion of formatted  text  than  text/enriched
  555.             can still use text/enriched as its basic representation, but
  556.             can extend it with new formatting  commands  and  by  hiding
  557.             information    specific   to   that   software   system   in
  558.             text/enriched comments.   As  such  systems  evolve,  it  is
  559.             expected  that  the  definition  of  text/enriched  will  be
  560.             further refined  by  future  published  specifications,  but
  561.             text/enriched  as  defined here provides a platform on which
  562.             evolutionary refinements can be based.
  563.  
  564.  
  565.  
  566.  
  567.  
  568.             Borenstein - text/eExpires September 1, 1993         Page 10
  569.  
  570.  
  571.  
  572.  
  573.             Borenstein     A text/enriched type for MIME April 1993 [11]
  574.  
  575.  
  576.             An expected common way that sophisticated mail programs will
  577.             generate    text/enriched    data    is   as   part   of   a
  578.             multipart/alternative construct.  For example, a mail  agent
  579.             that  can  generate enriched mail in ODA format can generate
  580.             that mail in a more widely interoperable form by  generating
  581.             both text/enriched and ODA versions of the same data, e.g.:
  582.  
  583.                  Content-type: multipart/alternative; boundary=foo
  584.  
  585.                  --foo
  586.                  Content-type: text/enriched
  587.  
  588.                  [text/enriched version of data]
  589.                  --foo
  590.                  Content-type: application/oda
  591.  
  592.                  [ODA version of data]
  593.                  --foo--
  594.  
  595.             If such a message  is  read  using  a  MIME-conformant  mail
  596.             reader  that  understands  ODA,  the  ODA  version  will  be
  597.             displayed; otherwise,  the  text/enriched  version  will  be
  598.             shown.
  599.  
  600.             In some environments, it  might  be  impossible  to  combine
  601.             certain text/enriched formatting commands, whereas in others
  602.             they might be combined easily.  For example, the combination
  603.             of <bold> and <italic> might produce bold italics on systems
  604.             that support such fonts, but there exist  systems  that  can
  605.             make  text bold or italicized, but not both.  In such cases,
  606.             the most recently issued (innermost)  recognized  formatting
  607.             command should be preferred.
  608.  
  609.             One of the major goals in the design of text/enriched was to
  610.             make it so simple that even text-only mailers will implement
  611.             enriched-to-plain-text  translators,  thus  increasing   the
  612.             likelihood that enriched text will become "safe" to use very
  613.             widely.  To demonstrate this simplicity, an extremely simple
  614.             C  program that converts text/enriched input into plain text
  615.             output is included in Appendix A.
  616.  
  617.             Extensions to text/enriched
  618.  
  619.  
  620.             It is expected that various mail system authors will  desire
  621.             extensions   to   text/enriched.   The   simple   syntax  of
  622.  
  623.  
  624.  
  625.             Borenstein - text/eExpires September 1, 1993         Page 11
  626.  
  627.  
  628.  
  629.  
  630.             Borenstein     A text/enriched type for MIME April 1993 [12]
  631.  
  632.  
  633.             text/enriched,  and  the  specification  that   unrecognized
  634.             formatting  commands should simply be ignored, are intend to
  635.             promote such extensions.  To facilitate  the  evolution  and
  636.             interoperability  of  such  extensions,  this  document also
  637.             defines an  "extensions"  parameter  by  which  the  use  of
  638.             publicly-defined text/enriched extensions can be declared as
  639.             a comma-separated list of extension names.  For  example,  a
  640.             text/enriched  object  that  includes  extensions  from  the
  641.             Andrew and Slate extension sets might  have  a  content-type
  642.             field of
  643.  
  644.                  Content-type:  text/enriched;
  645.                       extensions="Andrew,Slate"
  646.  
  647.             Note, however, that the  Andrew  and  Slate  extensions  are
  648.             hypothetical as of the publication of this document.
  649.  
  650.             An extension will typically define a whole set of  extension
  651.             commands for a particular purpose or application.
  652.  
  653.             As a useful example of the mechanism, one  could  define  an
  654.             extension  called "color". If the color extension were used,
  655.             a new set of formatting commands would be  defined,  of  the
  656.             form: "<colorname>" where colorname is a string that names a
  657.             color using some standard  naming  convention.   Thus,  mail
  658.             that included color might look like:
  659.  
  660.                  Subject: Blue moon, lady in red
  661.                  Content-type: text/enriched, extensions="color"
  662.  
  663.                  I want to take my <red>lady</red> to the
  664.                  <blue>moon</blue>.
  665.  
  666.             Note, however, that this extension is NOT  formally  defined
  667.             by  this  document,  primarily  for want of a standard color
  668.             naming convention.  It could easily be defined  by  a  later
  669.             document, however.
  670.  
  671.             Extension  names   beginning   with   "x-"   may   be   used
  672.             experimentally.     Standardized    extensions   should   be
  673.             registered with IANA using  the  process  defined  in  [RFC-
  674.             MIME].   Extension  names  are case-insensitive, so "Color",
  675.             "color", and "cOlOR" are equivalent in  effect,  if  not  in
  676.             good taste.
  677.  
  678.  
  679.  
  680.  
  681.  
  682.             Borenstein - text/eExpires September 1, 1993         Page 12
  683.  
  684.  
  685.  
  686.  
  687.             Borenstein     A text/enriched type for MIME April 1993 [13]
  688.  
  689.  
  690.             Implementations   should    simply    ignore    unrecognized
  691.             extensions.     Since    text/enriched   extensions   define
  692.             additional commands, implementations  should  simply  ignore
  693.             such  commands.  This raises the obvious question of why the
  694.             extension in use needs to be declared at all.  The answer is
  695.             that   by   declaring   the   extension  mechanism  in  use,
  696.             cooperating implementations can extend  text/enriched  in  a
  697.             manner  that allows them to be sure that both share the same
  698.             interpretation of an extended command.
  699.             An Example
  700.  
  701.             Putting all this  together,  the  following  "text/enriched"
  702.             body  fragment,  presuming  the  eventual  definition  of  a
  703.             "colors" extension:
  704.  
  705.                       From: Nathaniel Borenstein <nsb@bellcore.com>
  706.                       To: Ned Freed <ned@innosoft.com>
  707.                       Content-type: text/enriched; extensions=color
  708.  
  709.                       <bold>Now</bold> is the time for
  710.                       <italic>all</italic> good men
  711.                        <smaller>(and <<women>)</smaller> to
  712.                       <ignoreme>come</ignoreme>
  713.  
  714.                       to the aid of their
  715.  
  716.  
  717.                       <red>beloved</red> country. <comment> Stupid
  718.                        quote! </comment>
  719.                       <verbatim>
  720.                       By the way, I think that <smaller>
  721.                       should
  722.                       REALLY be called
  723.                       <tinier>
  724.                       and that <comment> and </comment> are for
  725.                       weenies.
  726.                       -- the end
  727.                       </verbatim>
  728.  
  729.             represents the following  formatted  text  (which  will,  no
  730.             doubt,  look  somewhat  cryptic  in the text-only version of
  731.             this document):
  732.  
  733.                  Now is the time for all good men (and <women>)  to
  734.                  come
  735.  
  736.  
  737.  
  738.  
  739.             Borenstein - text/eExpires September 1, 1993         Page 13
  740.  
  741.  
  742.  
  743.  
  744.             Borenstein     A text/enriched type for MIME April 1993 [14]
  745.  
  746.  
  747.                  to the aid of their
  748.  
  749.                  beloved country.
  750.                  By the way, I think that <smaller>
  751.                  should
  752.                  REALLY be called
  753.                  <tinier>
  754.                  and that <comment> and </comment> are for weenies.
  755.                  -- the end
  756.  
  757.             where the word "beloved" would be in red on a color display.
  758.  
  759.           Security Considerations
  760.  
  761.             Security issues are not  discussed  in  this  memo,  as  the
  762.             mechanism raises no security issues.
  763.  
  764.           Author's Address
  765.  
  766.             For more information, the author of  this  document  may  be
  767.             contacted via Internet mail:
  768.  
  769.                                 Nathaniel S. Borenstein
  770.                                  MRE 2D-296, Bellcore
  771.                                      445 South St.
  772.                                Morristown, NJ 07962-1910
  773.  
  774.                                 Phone: +1 201 829 4270
  775.                                  Fax:  +1 201 829 5963
  776.                                 Email: nsb@bellcore.com
  777.  
  778.             Acknowledgements
  779.  
  780.  
  781.             This document  reflects  the  input  of  many  contributors,
  782.             readers,    and    implementors   of   the   original   MIME
  783.             specification, RFC 1341.  The current  draft  also  reflects
  784.             particular contributions and comments from Terry Crowley and
  785.             Rhys Weatherley.
  786.  
  787.           References
  788.  
  789.             [RFC-1341]   Borenstein,   N.,   and   N.   Freed,     "MIME
  790.             (Multipurpose  Internet  Mail  Extensions):  Mechanisms  for
  791.             Specifying and Describing the  Format  of  Internet  Message
  792.             Bodies", RFC 1341, June, 1992.
  793.  
  794.  
  795.  
  796.             Borenstein - text/eExpires September 1, 1993         Page 14
  797.  
  798.  
  799.  
  800.  
  801.             Borenstein     A text/enriched type for MIME April 1993 [15]
  802.  
  803.  
  804.             [RFC-MIME]   Borenstein,   N.,   and   N.   Freed,     "MIME
  805.             (Multipurpose    Internet   Mail   Extensions)   Part   One:
  806.             Mechanisms for  Specifying  and  Describing  the  Format  of
  807.             Internet Message Bodies", RFC ********, *****, 1993.
  808.  
  809.             Appendix A -- A Simple enriched-to-plain Translator in C
  810.  
  811.  
  812.             One of the major goals in the design  of  the  text/enriched
  813.             subtype  of  the text Content-Type is to make formatted text
  814.             so  simple  that  even  text-only  mailers  will   implement
  815.             enriched-to-plain-text   translators,  thus  increasing  the
  816.             likelihood that multifont text will  become  "safe"  to  use
  817.             very  widely.   To demonstrate this simplicity, what follows
  818.             is a simple C program that converts text/enriched input into
  819.             plain  text  output.   Note that the UNIX newline convention
  820.             (the single character represented by  "\n")  is  assumed  by
  821.             this program.
  822.  
  823.                  #include <stdio.h>
  824.                  #include <ctype.h>
  825.  
  826.                  main() {
  827.                      int c, i, commct=0, newlinect=0, verbatim=0;
  828.                      char token[42], *p;
  829.  
  830.                      while ((c=getc(stdin)) != EOF) {
  831.                          if (c == '<') {
  832.                              if (verbatim != 0) {
  833.                                  for (i=0, p=token; (*p++ = getc(stdin))
  834.                  != EOF
  835.                                      && !lc2strncmp(token, "/verbatim>",
  836.                  i+1) && i<9; i++) {}
  837.                                  if (i==9) {
  838.                                      verbatim = 0;
  839.                                  } else {
  840.                                      *p = '\0';
  841.                                      putc('<', stdout);
  842.                                      fputs(token, stdout);
  843.                                  }
  844.                                  continue;
  845.                              } else {
  846.                                  newlinect=0;
  847.                                  c = getc(stdin);
  848.  
  849.  
  850.  
  851.  
  852.  
  853.             Borenstein - text/eExpires September 1, 1993         Page 15
  854.  
  855.  
  856.  
  857.  
  858.             Borenstein     A text/enriched type for MIME April 1993 [16]
  859.  
  860.  
  861.                                  if (c == '<') {
  862.                                      putc(c, stdout);
  863.                                  } else {
  864.                                      ungetc(c, stdin);
  865.                                      for (i=0, p=token; (c=getc(stdin))
  866.                  != EOF && c != '>'; i++) {
  867.                                          if (i < 41) *p++ = isupper(c) ?
  868.                  tolower(c) : c;
  869.                                      }
  870.                                      *p = '\0';
  871.                                      if (c == EOF) break;
  872.                                      if (strcmp(token, "comment") == 0
  873.                                          || strcmp(token, "extension")
  874.                  == 0)
  875.                                          commct++;
  876.                                      else if (strcmp(token, "verbatim")
  877.                  == 0)
  878.                                          verbatim = 1;
  879.                                      else if (strcmp(token, "/comment")
  880.                  == 0
  881.                                          || strcmp(token, "/extension")
  882.                  == 0)
  883.                                          commct--;
  884.                                  }
  885.                              }
  886.                       } else {
  887.                          if (commct > 0)
  888.                            ; /* ignore comments */
  889.                             else if (c == '\n' && verbatim == 0)
  890.                                 if (++newlinect > 1) {
  891.                                     putc(c, stdout);
  892.                                 } else {
  893.                                     putc(' ', stdout);
  894.                                 }
  895.                             else {
  896.                                 newlinect = 0;
  897.                                 putc(c, stdout);
  898.                             }
  899.                       }
  900.                      }
  901.                      putc('\n', stdout);
  902.                      exit(0);
  903.                  }
  904.  
  905.                  lc2strncmp(s1, s2, len)
  906.  
  907.  
  908.  
  909.  
  910.             Borenstein - text/eExpires September 1, 1993         Page 16
  911.  
  912.  
  913.  
  914.  
  915.             Borenstein     A text/enriched type for MIME April 1993 [17]
  916.  
  917.  
  918.                  char *s1, *s2;
  919.                  int len;
  920.                  {
  921.                      if (!s1 || !s2) return (-1);
  922.                      while (*s1 && *s2 && len > 0) {
  923.                       if (*s1 != *s2 && (tolower(*s1) != *s2)) return(-
  924.                  1);
  925.                       ++s1; ++s2; --len;
  926.                      }
  927.                      if (len <= 0) return(0);
  928.                      return((*s1 == *s2) ? 0 : -1);
  929.                  }
  930.             It should be noted that one can do considerably better  than
  931.             this  in  displaying  text/enriched data on a dumb terminal.
  932.             In particular, one can  replace  font  information  such  as
  933.             "bold"  with  textual emphasis (like *this* or   _T_H_I_S_).
  934.             One can also properly handle  the  text/enriched  formatting
  935.             commands  regarding  indentation, justification, and others.
  936.             However, the above program is all that is necessary in order
  937.             to  present text/enriched on a dumb terminal without showing
  938.             the user any formatting artifacts.
  939.  
  940.             Appendix B -- Differences from RFC 1341  text/richtext
  941.  
  942.             Text/enriched  is  a  clarification,   simplification,   and
  943.             refinement of the type defined as text/richtext in RFC 1341.
  944.             For the benefit of  those  who  are  already  familiar  with
  945.             text/richtext,   or  for  those  who  want  to  exploit  the
  946.             similarities to be able to display text/richtext  data  with
  947.             their  text/enriched  software,  the differences between the
  948.             two are summarized here. Note, however,  that  text/enriched
  949.             is  intended  to  make  text/richtext obsolete, so it is not
  950.             recommended that new software generate text/richtext.
  951.  
  952.             0.  The name "richtext" was changed to "enriched",  both  to
  953.             differentiate   the  two  versions  and  because  "richtext"
  954.             created widespread  confusion  with  Microsoft's  Rich  Text
  955.             Format (RTF).
  956.  
  957.             1.   Clarifications.   Many   things   were   ambiguous   or
  958.             unspecified  in  the  text/richtext definition, particularly
  959.             the  initial  state  and  the  semantics  of  richtext  with
  960.             multibyte  character  sets.   However,  such differences are
  961.             OPERATIONALLY irrelevant, since the  clarifications  offered
  962.             in  this document are at least reasonable interpretations of
  963.             the text/richtext specification.
  964.  
  965.  
  966.  
  967.             Borenstein - text/eExpires September 1, 1993         Page 17
  968.  
  969.  
  970.  
  971.  
  972.             Borenstein     A text/enriched type for MIME April 1993 [18]
  973.  
  974.  
  975.             2.  Newline semantics have changed.  In  text/richtext,  all
  976.             CRLFs  were mapped to spaces, and line breaks were indicated
  977.             by "<nl>".  This has been replaced by  the  "n-1"  rule  for
  978.             CRLFs.
  979.  
  980.             3.  The representation of a literal "<" character was "<lt>"
  981.             in text/richtext, but is "<<" in text/enriched.
  982.  
  983.             4.  The "verbatim" command did not exist in text/richtext.
  984.  
  985.             5.  The extensions parameter did not exist in text/richtext.
  986.  
  987.             6.  The following  commands  from  text/richtext  have  been
  988.             REMOVED   from   text/enriched:  <OUTDENT>,  <OUTDENTRIGHT>,
  989.             <SAMEPAGE>,    <SUBSCRIPT>,    <SUPERSCRIPT>,     <HEADING>,
  990.             <FOOTING>,    <ISO-8859-[1-9]>,   <US-ASCII>,   <PARAGRAPH>,
  991.             <SIGNATURE>, <NO-OP>, <LT>, <NL>, and <NP>.
  992.  
  993.             7.  All claims of  SGML  compatibility  have  been  dropped.
  994.             However,  with  the possible exceptions of the new semantics
  995.             for CRLF and "<<" can be implemented,  text/enriched  should
  996.             be no less SGML-friendly than text/richtext was.
  997.  
  998.             8.  In text/richtext, there were three commands (<NL>, <NP>,
  999.             and  <LT>)  that  did  not  use balanced closing delimiters.
  1000.             Since all of  these  have  been  eliminated,  there  are  NO
  1001.             exceptions to the nesting/balancing rules in text/enriched.
  1002.  
  1003.             9.  The limit on the size  of  formatting  tokens  has  been
  1004.             increased from 40 to 60 characters.
  1005.  
  1006.             10.   The  opentoken  and  closetoken  parameters  were  not
  1007.             present  in text/richtext, which always used "<" and ">", to
  1008.             the distress of implementers of text/richtext in Japanese.
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.             Borenstein - text/eExpires September 1, 1993         Page 18
  1025.  
  1026.  
  1027.